﻿using Microsoft.Phone.Controls;
using System;
using System.Reflection;
using System.Windows.Controls;
namespace BootyShaker
{
    public partial class AboutPage : UserControl
    {
        Action returnMethod;
        public AboutPage(Action returnMeth)
        {
            InitializeComponent();
            returnMethod = returnMeth;
            if (App.IsTrial)
            {
                btnBuy.Visibility = System.Windows.Visibility.Visible;
                txtBuy.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                btnBuy.Visibility = System.Windows.Visibility.Collapsed;
                txtBuy.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
        public void GoBack()
        {
            Hide.Begin();
            returnMethod();
        }
        private void Image_Rate(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Microsoft.Phone.Tasks.MarketplaceReviewTask marketplaceReviewTask = new Microsoft.Phone.Tasks.MarketplaceReviewTask();
            marketplaceReviewTask.Show();
        }

        private void Image_Buy(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //Show an application, using the default ContentType.
            Microsoft.Phone.Tasks.MarketplaceDetailTask marketplaceDetailTask = new Microsoft.Phone.Tasks.MarketplaceDetailTask();
            marketplaceDetailTask.Show();
        }
        private void Image_Email(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Microsoft.Phone.Tasks.EmailComposeTask emailcomposer = new Microsoft.Phone.Tasks.EmailComposeTask();
            emailcomposer.To = "bootyshaker@motif.lt";
            emailcomposer.Subject = "";
            emailcomposer.Body = "";
            emailcomposer.Show();

        }

        private void PhoneApplicationPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            Version v = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version;
            Version.Text = String.Format("Version {0}.{1}.{2}", v.Major, v.Minor, v.Build);
        
        }

        private void Show_Completed(object sender, EventArgs e)
        {
            if (App.IsTrial)
            {
                btnBuy.Visibility = System.Windows.Visibility.Visible;
                txtBuy.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                btnBuy.Visibility = System.Windows.Visibility.Collapsed;
                txtBuy.Visibility = System.Windows.Visibility.Collapsed;
            }
        }

        private void btnBack_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            GoBack();
        }

        private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Microsoft.Phone.Tasks.MarketplaceDetailTask marketplaceDetailTask = new Microsoft.Phone.Tasks.MarketplaceDetailTask();
            marketplaceDetailTask.ContentIdentifier = "94651a1e-7645-45f4-9f00-e5a68f3350d1";
            marketplaceDetailTask.Show();
        }

    }
}